// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

int t, n;

const int N = 2e5+50;

char s[N];

int main(int argc, char const *argv[]) {
    // code
    deque<char> Q;
    bool rev = false;
    scanf("%s", s);
    n = strlen(s);
    for (int i=0; i<n; ++i)
        Q.push_back(s[i]);
    int q;
    scanf("%d", &q);
    for (int i=0; i<q; ++i) {
        static int op[10];
        int t;
        scanf("%d", &t);
        --t;
        int f;
        if (t) scanf("%d%s", &f, op);
        --f;
        if (t == 0) {
            rev ^= 1;
        } else {
            f ^= rev;
            if (f == 0)
                Q.push_front(op[0]);
            else
                Q.push_back(op[0]);
        }
    }
    if (!rev)
        while (!Q.empty()) {
            putchar(Q.front());
            Q.pop_front();
        }
    else
        while (!Q.empty()) {
            putchar(Q.back());
            Q.pop_back();
        }
    putchar('\n');

    return 0;
}
